﻿#region Using directives

using System;
using System.ComponentModel;
using System.Reflection;
using NetROS.Tiers.Entities.Validation;

#endregion

namespace NetROS.Tiers.Entities
{
    ///<summary>
    /// An object representation of the 'tblPutniNalogAkontacija' table. [No description found the database]	
    ///</summary>
    /// <remarks>
    /// This file is generated once and will never be overwritten.
    /// </remarks>	
    [Serializable]
    [CLSCompliant(true)]
    public partial class PutniNalogAkontacija : PutniNalogAkontacijaBase
    {
        #region Constructors

        ///<summary>
        /// Creates a new <see cref="PutniNalogAkontacija"/> instance.
        ///</summary>
        public PutniNalogAkontacija() : base() { }

        #endregion
        protected override void AddValidationRules()
        {
            base.AddValidationRules();
            ValidationRules.AddRule(
              CheckIsIDNotSet,
               new ValidationRuleArgs("IDValuta", "Valutu"));

        }
        bool CheckIsIDNotSet(object target, ValidationRuleArgs e)
        {
            bool result = true;

            PropertyInfo p = target.GetType().GetProperty(e.PropertyName);

            int? value = (int?)p.GetValue(target, null);

            result = !value.Equals(0) && value != null;

            if (!result)
            {
                if (string.IsNullOrEmpty(e.Description)) e.Description = string.Format("Izaberite {0}", e.FriendlyName);
            }

            return result;
        }

    }
}
